var express = require('express');
var router = express.Router();
var captchapng = require('captchapng');

/* GET users listing. */
router.get('/', function(req, res, next) {
    var code = parseInt(Math.random() * 9000 + 1000);
    req.session.captcha = code;
    var p = new captchapng(100, 30, code);
    p.color(0, 0, 0, 0);
    p.color(80, 80, 80, 255);
    var img = p.getBase64();
    res.writeHead(200, {
        'Content-Type': 'image/png'
    });
    res.end(img);
});

module.exports = router;
